package com.fuershiye.woman.monitor.beans;

import java.io.Serializable;


/**
 * 
 * @author yongyongdong
 *
 */
public class Page implements Serializable {
	
	private static final long serialVersionUID = -668186643559193185L;
	
	private static final int PAGE = 1;
	private static final int PAGE_SIZE = 30;

	private Integer page;
    private Integer pageSize;
    
    public Page(Integer page, Integer pageSize){
    	if(page==null || page==0){
        	this.page=1;
    	}else{
        	this.page=page;
    	}
    	if(pageSize==null || pageSize==0){
        	this.pageSize=30;
    	}else{
        	this.pageSize=pageSize;
    	}
    }
    
	//size 		10
	//page 		1,	 2,		3
	//return 	0-9, 10-19,	20-29
    //start     0  , 10
    //max       9  , 
	public Integer getStart() {
		return (this.getPage()-1) * this.getPageSize();
	}
	
	public Integer getPageStart() {
		return (this.getPage()-1) * this.getPageSize();
	}
	
	public Integer getPageEnd() {
		return this.getPage() * this.getPageSize() -1;
	}
	
//	public Integer getMax() {
//		return (this.getPage() * this.getPageSize())-1;
//	}
    
    public Integer getPage() {
		if(page==null||page<1){
			return PAGE;
		}else{
			return page;
		}
	}
	public Integer getPageSize() {
		if(pageSize==null||pageSize<1){
			return PAGE_SIZE;
		}else{
			return pageSize;
		}
	}
	
	public void setPage(Integer page) {
		if(page==null||page<1){
			this.page = PAGE;
		}else{
			this.page = page;
		}
	}
	public void setPageSize(Integer pageSize) {
		if(pageSize==null||pageSize<1){
			this.pageSize = PAGE_SIZE;
		}else{
			this.pageSize = pageSize;
		}
	}
    
}
